Best approach to store Application Configuration

Best approach to store Application Configuration

am 11.07.2011 23:07:58 von Jerry Pereira

--bcaec520f721ef0d3404a7d1938c
Content-Type: text/plain; charset=ISO-8859-1

Hi All,

I am new to mod_perl (a java developer). I would like to know the best
approach to store and retrieve Applicaiton configurations that is accessible
to all packages in my mod_perl application.

My application configuration includes - Database details, Template mapping,
LDAP configuration details etc. I would like my to load all these
configuratoins when my application starts and then on, i should be able to
access these configuration from anywhere.

For Example:
my $dbDetails = ConfigUtil->getDBDetails(); //returns reference to hash
my dbUser = dbDetails->user;

I belive PerlSetVar only allows strings variables. I would like to get some
suggestions on how configuration management in mod_perl applications.

Thanks,
Jerry

--bcaec520f721ef0d3404a7d1938c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi All,

=A0

I am new to mod_perl (a java developer). I would like to know the best=
approach to store and retrieve Applicaiton configurations that is accessib=
le to all packages in my mod_perl application.

=A0

My application configuration includes - Database details, Template map=
ping, LDAP configuration details etc. I would like my to load all these con=
figuratoins when my application starts and then on, i should be able to acc=
ess these configuration from anywhere.


=A0

For Example:

my $dbDetails =3D ConfigUtil->getDBDetails(); //returns reference t=
o hash

my dbUser =3D dbDetails->user;

=A0

I belive PerlSetVar only allows strings variables. I would like to get=
some suggestions on how configuration management in mod_perl applications.=

=A0

Thanks,

Jerry


--bcaec520f721ef0d3404a7d1938c--

RE: Best approach to store Application Configuration

am 11.07.2011 23:16:11 von James.B.Muir

--_000_527C4914F1B2EA47B38422DE0FA05A650651BEE3BEDH201DHMCMa st_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

This page describes pretty well how to set up custom configuration directiv=
es; perhaps helpful?

http://perl.apache.org/docs/2.0/user/config/custom.html

-James

From: Jerry Pereira [mailto:online.jerry@gmail.com]
Sent: Monday, July 11, 2011 5:08 PM
To: modperl@perl.apache.org
Subject: Best approach to store Application Configuration

Hi All,

I am new to mod_perl (a java developer). I would like to know the best appr=
oach to store and retrieve Applicaiton configurations that is accessible to=
all packages in my mod_perl application.

My application configuration includes - Database details, Template mapping,=
LDAP configuration details etc. I would like my to load all these configur=
atoins when my application starts and then on, i should be able to access t=
hese configuration from anywhere.

For Example:
my $dbDetails =3D ConfigUtil->getDBDetails(); //returns reference to hash
my dbUser =3D dbDetails->user;

I belive PerlSetVar only allows strings variables. I would like to get some=
suggestions on how configuration management in mod_perl applications.

Thanks,
Jerry

IMPORTANT NOTICE REGARDING THIS ELECTRONIC MESSAGE:

This message is intended for the use of the person to whom it is addressed =
and may contain information that is privileged, confidential, and protected=
from disclosure under applicable law. If you are not the intended recipien=
t, your use of this message for any purpose is strictly prohibited. If you =
have received this communication in error, please delete the message and no=
tify the sender so that we may correct our records.

--_000_527C4914F1B2EA47B38422DE0FA05A650651BEE3BEDH201DHMCMa st_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:x=3D"urn:schemas-microsoft-com:office:excel" xmlns:p=3D"urn:schemas-m=
icrosoft-com:office:powerpoint" xmlns:a=3D"urn:schemas-microsoft-com:office=
:access" xmlns:dt=3D"uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s=3D"=
uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs=3D"urn:schemas-microsof=
t-com:rowset" xmlns:z=3D"#RowsetSchema" xmlns:b=3D"urn:schemas-microsoft-co=
m:office:publisher" xmlns:ss=3D"urn:schemas-microsoft-com:office:spreadshee=
t" xmlns:c=3D"urn:schemas-microsoft-com:office:component:spread sheet" xmlns=
:odc=3D"urn:schemas-microsoft-com:office:odc" xmlns:oa=3D"urn:schemas-micro=
soft-com:office:activation" xmlns:html=3D"http://www.w3.org/TR/REC-html40" =
xmlns:q=3D"http://schemas.xmlsoap.org/soap/envelope/" xmlns:rtc=3D"http://m=
icrosoft.com/officenet/conferencing" xmlns:D=3D"DAV:" xmlns:Repl=3D"http://=
schemas.microsoft.com/repl/" xmlns:mt=3D"http://schemas.microsoft.com/share=
point/soap/meetings/" xmlns:x2=3D"http://schemas.microsoft.com/office/excel=
/2003/xml" xmlns:ppda=3D"http://www.passport.com/NameSpace.xsd" xmlns:ois=
=3D"http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir=3D"http://=
schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds=3D"http://www.w3=
..org/2000/09/xmldsig#" xmlns:dsp=3D"http://schemas.microsoft.com/sharepoint=
/dsp" xmlns:udc=3D"http://schemas.microsoft.com/data/udc" xmlns:xsd=3D"http=
://www.w3.org/2001/XMLSchema" xmlns:sub=3D"http://schemas.microsoft.com/sha=
repoint/soap/2002/1/alerts/" xmlns:ec=3D"http://www.w3.org/2001/04/xmlenc#"=
xmlns:sp=3D"http://schemas.microsoft.com/sharepoint/" xmlns:sps=3D"http://=
schemas.microsoft.com/sharepoint/soap/" xmlns:xsi=3D"http://www.w3.org/2001=
/XMLSchema-instance" xmlns:udcs=3D"http://schemas.microsoft.com/data/udc/so=
ap" xmlns:udcxf=3D"http://schemas.microsoft.com/data/udc/xmlfile " xmlns:udc=
p2p=3D"http://schemas.microsoft.com/data/udc/parttopart" xmlns:wf=3D"http:/=
/schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:dsss=3D"http://sche=
mas.microsoft.com/office/2006/digsig-setup" xmlns:dssi=3D"http://schemas.mi=
crosoft.com/office/2006/digsig" xmlns:mdssi=3D"http://schemas.openxmlformat=
s.org/package/2006/digital-signature" xmlns:mver=3D"http://schemas.openxmlf=
ormats.org/markup-compatibility/2006" xmlns:m=3D"http://schemas.microsoft.c=
om/office/2004/12/omml" xmlns:mrels=3D"http://schemas.openxmlformats.org/pa=
ckage/2006/relationships" xmlns:spwp=3D"http://microsoft.com/sharepoint/web=
partpages" xmlns:ex12t=3D"http://schemas.microsoft.com/exchange/service s/20=
06/types" xmlns:ex12m=3D"http://schemas.microsoft.com/exchange/service s/200=
6/messages" xmlns:pptsl=3D"http://schemas.microsoft.com/sharepoint/soap/ Sli=
deLibrary/" xmlns:spsl=3D"http://microsoft.com/webservices/SharePointPor tal=
Server/PublishedLinksService" xmlns:Z=3D"urn:schemas-microsoft-com:" xmlns:=
st=3D"" xmlns=3D"http://www.w3.org/TR/REC-html40">

>





libri","sans-serif";color:#1F497D">This page describes prett=
y well how to set up custom configuration directives; perhaps helpful?=


libri","sans-serif";color:#1F497D"> <=
/p>

libri","sans-serif";color:#1F497D"> ache.org/docs/2.0/user/config/custom.html">http://perl.apach e.org/docs/2.0/=
user/config/custom.html


libri","sans-serif";color:#1F497D"> <=
/p>

libri","sans-serif";color:#1F497D">-James<=
/p>

libri","sans-serif";color:#1F497D"> <=
/p>

0in 0in">

;Tahoma","sans-serif"">From: ize:10.0pt;font-family:"Tahoma","sans-serif""> Jerry Pe=
reira [mailto:online.jerry@gmail.com]


Sent: Monday, July 11, 2011 5:08 PM

To: modperl@perl.apache.org

Subject: Best approach to store Application Configuration=



 



Hi All,




 




I am new to mod_perl (a java developer). I would lik=
e to know the best approach to store and retrieve Applicaiton configuration=
s that is accessible to all packages in my mod_perl application.=




 




My application configuration includes - Database det=
ails, Template mapping, LDAP configuration details etc. I would like my to =
load all these configuratoins when my application starts and then on, i sho=
uld be able to access these configuration
from anywhere.




 




For Example:




my $dbDetails =3D ConfigUtil->getDBDetails(); //r=
eturns reference to hash




my dbUser =3D dbDetails->user;




 




I belive PerlSetVar only allows strings variables. I=
would like to get some suggestions on how configuration management in mod_=
perl applications.




 




Thanks,




Jerry






IMPORTANT NOTICE REGARDIN=
G THIS ELECTRONIC MESSAGE:



This message is intended for the use of the person to whom it is addressed =
and may contain information that is privileged, confidential, and protected=
from disclosure under applicable law. If you are not the intended recipien=
t, your use of this message for
any purpose is strictly prohibited. If you have received this communicatio=
n in error, please delete the message and notify the sender so that we may =
correct our records.





--_000_527C4914F1B2EA47B38422DE0FA05A650651BEE3BEDH201DHMCMa st_--

RE: Best approach to store Application Configuration

am 11.07.2011 23:21:44 von Edward.Szekeres

--_000_D4703BE836D28841863FE6226C9DAA7405B500amermbx01perkin el_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Database

Flatfile on disk (look up Storable module on how to save/load binary repre=
sentation of PERL structures), works well if you want to have an "instant s=
tructure", but flatfiles need location on the server.

I use both regularly

From: Jerry Pereira [mailto:online.jerry@gmail.com]
Sent: Monday, July 11, 2011 5:08 PM
To: modperl@perl.apache.org
Subject: Best approach to store Application Configuration

Hi All,

I am new to mod_perl (a java developer). I would like to know the best appr=
oach to store and retrieve Applicaiton configurations that is accessible to=
all packages in my mod_perl application.

My application configuration includes - Database details, Template mapping,=
LDAP configuration details etc. I would like my to load all these configur=
atoins when my application starts and then on, i should be able to access t=
hese configuration from anywhere.

For Example:
my $dbDetails =3D ConfigUtil->getDBDetails(); //returns reference to hash
my dbUser =3D dbDetails->user;

I belive PerlSetVar only allows strings variables. I would like to get some=
suggestions on how configuration management in mod_perl applications.

Thanks,
Jerry

--_000_D4703BE836D28841863FE6226C9DAA7405B500amermbx01perkin el_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">

>





libri","sans-serif";color:#1F497D">Database >


libri","sans-serif";color:#1F497D"> <=
/p>

libri","sans-serif";color:#1F497D">Flatfile on disk (look up=
Storable module on how to save/load  binary representation of PERL st=
ructures), works well if you want to have an “instant structure”=
;,
but flatfiles need location on the server.


libri","sans-serif";color:#1F497D"> <=
/p>

libri","sans-serif";color:#1F497D">I use both regularly=


libri","sans-serif";color:#1F497D"> <=
/p>

;Tahoma","sans-serif"">From: ize:10.0pt;font-family:"Tahoma","sans-serif""> Jerry Pe=
reira [mailto:online.jerry@gmail.com]


Sent: Monday, July 11, 2011 5:08 PM

To: modperl@perl.apache.org

Subject: Best approach to store Application Configuration=


 



Hi All,




 




I am new to mod_perl (a java developer). I would lik=
e to know the best approach to store and retrieve Applicaiton configuration=
s that is accessible to all packages in my mod_perl application.=




 




My application configuration includes - Database det=
ails, Template mapping, LDAP configuration details etc. I would like my to =
load all these configuratoins when my application starts and then on, i sho=
uld be able to access these configuration
from anywhere.




 




For Example:




my $dbDetails =3D ConfigUtil->getDBDetails(); //r=
eturns reference to hash




my dbUser =3D dbDetails->user;




 




I belive PerlSetVar only allows strings variables. I=
would like to get some suggestions on how configuration management in mod_=
perl applications.




 




Thanks,




Jerry







--_000_D4703BE836D28841863FE6226C9DAA7405B500amermbx01perkin el_--

Re: Best approach to store Application Configuration

am 11.07.2011 23:23:03 von mpeters

On 07/11/2011 05:16 PM, James B. Muir wrote:
> This page describes pretty well how to set up custom configuration
> directives; perhaps helpful?
>
> http://perl.apache.org/docs/2.0/user/config/custom.html

I would almost always avoid this kind of configuration and go with an
external configuration file. Every project of any decent size will have
some scripts or processes that don't run under mod_perl and thus can't
use this apache-only configuration.

As for configuration in Perl if I were starting a new project, I'd
probably go with something like Config::Any and then pick a backend
format. But in practice it probably doesn't matter a whole lot which
config module you use as long as it's not tied to Apache. But if you
like the apache-style format you can use Config::ApacheFormat which
works well.

--
Michael Peters
Plus Three, LP

Re: Best approach to store Application Configuration

am 11.07.2011 23:26:41 von Jeff McCarrell

--_000_CA40B608340Ejmccarreakamaicom_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi Jerry.

I went through a couple of different approaches before settling on using YA=
ML files to describe configuration.
There are several nice properties of YAML IMO, not least of which is arbitr=
ary nesting so the config can closely match the software being configured.
Here is a sanitized example of my production config:

# -*- mode: perl -*-
# configuration file for XXX
config: { version: 1 }

# XYZ configuration
# across the entire XXX tier
xyz: {
# enable / disable all ...
feature_X_enabled: true,

# name of cookie(s) to emit: [xx, yy, zz]
emit_cookies: [ xx ]

# substructure configuration
sub_structures: {
disabled: {
foo: [],
bar: [],
baz: [],
}
}
}

There are several YAML readers available; I preferred YAML::XS because of i=
ts speed and correctness.
My apps need to run a long time, so they poll the configuration file every =
n seconds, and reload it if needed.
Overall, I was pretty happy with this approach, and so were the operations =
folks who have to configure the settings in production.

HTH,
-- jeff

From: Jerry Pereira >
Date: Mon, 11 Jul 2011 16:07:58 -0500
To: "modperl@perl.apache.org" ..apache.org>
Subject: Best approach to store Application Configuration

Hi All,

I am new to mod_perl (a java developer). I would like to know the best appr=
oach to store and retrieve Applicaiton configurations that is accessible to=
all packages in my mod_perl application.

My application configuration includes - Database details, Template mapping,=
LDAP configuration details etc. I would like my to load all these configur=
atoins when my application starts and then on, i should be able to access t=
hese configuration from anywhere.

For Example:
my $dbDetails =3D ConfigUtil->getDBDetails(); //returns reference to hash
my dbUser =3D dbDetails->user;

I belive PerlSetVar only allows strings variables. I would like to get some=
suggestions on how configuration management in mod_perl applications.

Thanks,
Jerry

--_000_CA40B608340Ejmccarreakamaicom_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-si=
ze: 14px; font-family: Calibri, sans-serif; ">

Hi Jerry.

=
I went through a couple of different approaches before settling =
on using YAML files to describe configuration.
There are several =
nice properties of YAML IMO, not least of which is arbitrary nesting so the=
config can closely match the software being configured.
Here is =
a sanitized example of my production config:

=
# -*- mode: perl -*-
# configuration file for XXX
confi=
g: { version: 1 }

# XYZ configuration
# =
 across the entire XXX tier
xyz: {
  # e=
nable / disable all ...
  feature_X_enabled: true, >

  # name of cookie(s) to emit: [xx, yy, zz]<=
/div>
  emit_cookies: [ xx ]

 &=
nbsp;# substructure configuration
  sub_structures: { div>
    disabled: {
      =
;foo: [],
      bar: [],
 &nbs=
p;    baz: [],
    }
 &nb=
sp;}
}

There are several YAML read=
ers available; I preferred YAML::XS because of its speed and correctness. div>
My apps need to run a long time, so they poll the configuration fi=
le every n seconds, and reload it if needed.
Overall, I was prett=
y happy with this approach, and so were the operations folks who have to co=
nfigure the settings in production.

HTH,
>-- jeff

"font-family: Calibri; font-size: 15px; ">=
From:
Jerry Pereira <o=
nline.jerry@gmail.com
>
>
black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM=
: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid=
; BORDER-RIGHT: medium none; PADDING-TOP: 3pt"> old">Date: Mon, 11 Jul 2011 16:07:58 -0500
eight:bold">To: "modperl=
@perl.apache.org
" <modper=
l@perl.apache.org
>
Subject: an> Best approach to store Application Configuration

v>
Hi All,
 
I am new to mod_perl (a java deve=
loper). I would like to know the best approach to store and retrieve Applic=
aiton configurations that is accessible to all packages in my mod_perl appl=
ication.
 
My application configuration includes -=
Database details, Template mapping, LDAP configuration details etc. I woul=
d like my to load all these configuratoins when my application starts and t=
hen on, i should be able to access these configuration from anywhere. >
 
For Example:
my $dbDetails =3D ConfigUtil-=
>getDBDetails(); //returns reference to hash
my dbUser =3D dbD=
etails->user;
 
I belive PerlSetVar only allows=
strings variables. I would like to get some suggestions on how configurati=
on management in mod_perl applications.
 
Thanks,<=
/div>
Jerry


--_000_CA40B608340Ejmccarreakamaicom_--

Re: Best approach to store Application Configuration

am 11.07.2011 23:35:04 von Fred Moyer

On Mon, Jul 11, 2011 at 2:23 PM, Michael Peters wrote:
> On 07/11/2011 05:16 PM, James B. Muir wrote:
>>
>> This page describes pretty well how to set up custom configuration
>> directives; perhaps helpful?
>>
>> http://perl.apache.org/docs/2.0/user/config/custom.html
>
> I would almost always avoid this kind of configuration and go with an
> external configuration file. Every project of any decent size will have some
> scripts or processes that don't run under mod_perl and thus can't use this
> apache-only configuration.

This kind of configuration has the advantage of avoiding the overhead
associated with PerlSetVar if I recall correctly. The downside is
that the custom config directives can be a bit tricky to setup
correctly.

> As for configuration in Perl if I were starting a new project, I'd probably
> go with something like Config::Any and then pick a backend format.

+1

Re: Best approach to store Application Configuration

am 11.07.2011 23:41:13 von Jerry Pereira

--bcaec520f721d0692e04a7d20a95
Content-Type: text/plain; charset=ISO-8859-1

please correct me if I am wrong, I should be using tool like
YAML/Config::General for application configuration storage and reteieval,
and load them on startup using startup.pl script? That would mean i will
have to store the name of configuration file some where (probabaly in
mod_perl configuration block in httpd.conf).

On Mon, Jul 11, 2011 at 2:26 PM, McCarrell, Jeff wrote:

> Hi Jerry.
>
> I went through a couple of different approaches before settling on using
> YAML files to describe configuration.
> There are several nice properties of YAML IMO, not least of which is
> arbitrary nesting so the config can closely match the software being
> configured.
> Here is a sanitized example of my production config:
>
> # -*- mode: perl -*-
> # configuration file for XXX
> config: { version: 1 }
>
> # XYZ configuration
> # across the entire XXX tier
> xyz: {
> # enable / disable all ...
> feature_X_enabled: true,
>
> # name of cookie(s) to emit: [xx, yy, zz]
> emit_cookies: [ xx ]
>
> # substructure configuration
> sub_structures: {
> disabled: {
> foo: [],
> bar: [],
> baz: [],
> }
> }
> }
>
> There are several YAML readers available; I preferred YAML::XS because of
> its speed and correctness.
> My apps need to run a long time, so they poll the configuration file every
> n seconds, and reload it if needed.
> Overall, I was pretty happy with this approach, and so were the operations
> folks who have to configure the settings in production.
>
> HTH,
> -- jeff
>
> From: Jerry Pereira
> Date: Mon, 11 Jul 2011 16:07:58 -0500
> To: "modperl@perl.apache.org"
>
> Subject: Best approach to store Application Configuration
>
> Hi All,
>
> I am new to mod_perl (a java developer). I would like to know the best
> approach to store and retrieve Applicaiton configurations that is accessible
> to all packages in my mod_perl application.
>
> My application configuration includes - Database details, Template mapping,
> LDAP configuration details etc. I would like my to load all these
> configuratoins when my application starts and then on, i should be able to
> access these configuration from anywhere.
>
> For Example:
> my $dbDetails = ConfigUtil->getDBDetails(); //returns reference to hash
> my dbUser = dbDetails->user;
>
> I belive PerlSetVar only allows strings variables. I would like to get some
> suggestions on how configuration management in mod_perl applications.
>
> Thanks,
> Jerry
>



--
Your clothes may be the latest in style but you aint completely dressed
until you wear a smile!
Keep smiling : )

--bcaec520f721d0692e04a7d20a95
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

please correct me if I am wrong, I should be using tool like YAML/Config::G=
eneral for application configuration storage and reteieval, and load them o=
n startup using=A0 script? That=
would mean i will have to store the name of configuration file some where =
(probabaly in mod_perl configuration block in httpd.conf).



On Mon, Jul 11, 2011 at 2:26 PM, McCarrell, Jeff=
<jmccarre@akam=
ai.com
>
wrote:

; PADDING-LEFT: 1ex" class=3D"gmail_quote">
R: rgb(0,0,0); FONT-SIZE: 14px">
Hi Jerry.



I went through a couple of different approaches before settling on usi=
ng YAML files to describe configuration.

There are several nice properties of YAML IMO, not least of which is a=
rbitrary nesting so the config can closely match the software being configu=
red.

Here is a sanitized example of my production config:




# -*- mode: perl -*-

# configuration file for XXX

config: { version: 1 }



# XYZ configuration

# =A0across the entire XXX tier

xyz: {

  # enable / disable all ...

  feature_X_enabled: true,



  # name of cookie(s) to emit: [xx, yy, zz]

  emit_cookies: [ xx ]



  # substructure configuration

  sub_structures: {

   =A0disabled: {

   =A0 =A0foo: [],

   =A0 =A0bar: [],

   =A0 =A0baz: [],

   =A0}

  }

}



There are several YAML readers available; I preferred YAML::XS because=
of its speed and correctness.

My apps need to run a long time, so they poll the configuration file e=
very n seconds, and reload it if needed.

Overall, I was pretty happy with this approach, and so were the operat=
ions folks who have to configure the settings in production.



HTH,

-- jeff



ONT-WEIGHT: bold">From: Jerry Pereira < erry@gmail.com" target=3D"_blank">online.jerry@gmail.com> v>
dium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; FONT=
-FAMILY: Calibri; COLOR: black; FONT-SIZE: 11pt; BORDER-TOP: #b5c4df 1pt so=
lid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
Date: Mon, 11 Jul 2011 16:07:58 -0=
500
To: " :modperl@perl.apache.org" target=3D"_blank">modperl@perl.apache.org&quo=
t; <modperl=
@perl.apache.org
>=20

Subject: Bes=
t approach to store Application Configuration






Hi All,

=A0

I am new to mod_perl (a java developer). I would like to know the best=
approach to store and retrieve Applicaiton configurations that is accessib=
le to all packages in my mod_perl application.

=A0

My application configuration includes - Database details, Template map=
ping, LDAP configuration details etc. I would like my to load all these con=
figuratoins when my application starts and then on, i should be able to acc=
ess these configuration from anywhere.


=A0

For Example:

my $dbDetails =3D ConfigUtil->getDBDetails(); //returns reference t=
o hash

my dbUser =3D dbDetails->user;

=A0

I belive PerlSetVar only allows strings variables. I would like to get=
some suggestions on how configuration management in mod_perl applications.=

=A0

Thanks,

Jerry


=3D"all">
--
Your clothes may be the latest in style but you aint co=
mpletely dressed until you wear a smile!
Keep smiling : )


--bcaec520f721d0692e04a7d20a95--

RE: Best approach to store Application Configuration

am 11.07.2011 23:42:04 von James.B.Muir

The PerlSetVar overhead occurs on every request, whereas the overhead assoc=
iated with using the custom configuration occurs once when Apache is starte=
d.
-James


-----Original Message-----
From: Fred Moyer [mailto:fred@redhotpenguin.com]
Sent: Monday, July 11, 2011 5:35 PM
To: Michael Peters
Cc: James B. Muir; Jerry Pereira; modperl@perl.apache.org
Subject: Re: Best approach to store Application Configuration

On Mon, Jul 11, 2011 at 2:23 PM, Michael Peters wro=
te:
> On 07/11/2011 05:16 PM, James B. Muir wrote:
>>
>> This page describes pretty well how to set up custom configuration
>> directives; perhaps helpful?
>>
>> http://perl.apache.org/docs/2.0/user/config/custom.html
>
> I would almost always avoid this kind of configuration and go with an
> external configuration file. Every project of any decent size will have s=
ome
> scripts or processes that don't run under mod_perl and thus can't use thi=
s
> apache-only configuration.

This kind of configuration has the advantage of avoiding the overhead
associated with PerlSetVar if I recall correctly. The downside is
that the custom config directives can be a bit tricky to setup
correctly.

> As for configuration in Perl if I were starting a new project, I'd probab=
ly
> go with something like Config::Any and then pick a backend format.

+1

IMPORTANT NOTICE REGARDING THIS ELECTRONIC MESSAGE:

This message is intended for the use of the person to whom it is addressed =
and may contain information that is privileged, confidential, and protected=
from disclosure under applicable law. If you are not the intended recipie=
nt, your use of this message for any purpose is strictly prohibited. If yo=
u have received this communication in error, please delete the message and =
notify the sender so that we may correct our records.

Re: Best approach to store Application Configuration

am 12.07.2011 00:03:20 von Jeff McCarrell

--_000_CA40BED4342Ejmccarreakamaicom_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Naming the path to the config file in an httpd conf will certainly work.
In my case, the path the config file is hard coded in the method that reads=
the config as it is not something that changes.

Here is on of my httpd conf file (a separate file loaded in the http config=
uration directory so your install process doesn't have to change the actual=
httpd.conf):
PerlModule Your::App
PerlPostConfigHandler Your::App::httpd_start


SetHandler modperl
PerlResponseHandler +Your::App

# Apache::DBI needs GlobalRequest
PerlOptions +GlobalRequest


The httpd_start method gets called at apache startup time, and reads the co=
nfig in once.

Also, one other possible advantage to YAML is that YAML is not perl, so if =
you have a mixed language env,
it is easy to share/move/port your config to the language of your choice.
YAML has pretty good support across the common languages you will find in t=
he LAMP world.

BTW, if you haven't already done so, I recommend becoming familiar with the=
handlers and their life cycles:
http://perl.apache.org/docs/2.0/user/handlers/server.html
http://perl.apache.org/docs/2.0/user/handlers/http.html#HTTP _Request_Cycle_=
Phases

Have fun,

-- jeff

From: Jerry Pereira >
Date: Mon, 11 Jul 2011 16:41:13 -0500
To: Jeff McCarrell >
Cc: "modperl@perl.apache.org" ..apache.org>
Subject: Re: Best approach to store Application Configuration

please correct me if I am wrong, I should be using tool like YAML/Config::G=
eneral for application configuration storage and reteieval, and load them o=
n startup using startup.pl script? That would mean i wil=
l have to store the name of configuration file some where (probabaly in mod=
_perl configuration block in httpd.conf).



--_000_CA40BED4342Ejmccarreakamaicom_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-si=
ze: 14px; font-family: Calibri, sans-serif; ">

Naming the path to the c=
onfig file in an httpd conf will certainly work.
In my case, the =
path the config file is hard coded in the method that reads the config as i=
t is not something that changes.

Here is on of my =
httpd conf file (a separate file loaded in the http configuration directory=
so your install process doesn't have to change the actual httpd.conf): v>
PerlModule    Your::App
PerlPostConfigHandl=
er Your::App::httpd_start

<Location /foo/app>=
;
    SetHandler modperl
   &n=
bsp;PerlResponseHandler   +Your::App

 &n=
bsp;  # Apache::DBI needs GlobalRequest
    P=
erlOptions +GlobalRequest
</Location>

<=
/div>
The httpd_start method gets called at apache startup time, and re=
ads the config in once.

Also, one other possible a=
dvantage to YAML is that YAML is not perl, so if you have a mixed language =
env, 
it is easy to share/move/port your config to the langu=
age of your choice.
YAML has pretty good support across the commo=
n languages you will find in the LAMP world.

BTW, =
if you haven't already done so, I recommend becoming familiar with the hand=
lers and their life cycles:
s/2.0/user/handlers/server.html">http://perl.apache.org/docs /2.0/user/handl=
ers/server.html
er/handlers/http.html#HTTP_Request_Cycle_Phases">http://perl .apache.org/doc=
s/2.0/user/handlers/http.html#HTTP_Request_Cycle_Phases

<=
/div>
Have fun,

-- jeff

pan id=3D"OLK_SRC_BODY_SECTION">
e:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LE=
FT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in=
; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3p=
t">From: Jerry Pereira < =3D"mailto:online.jerry@gmail.com">online.jerry@gmail.com>
style=3D"font-weight:bold">Date: Mon, 11 Jul 2011 16:41:13 -0500 >To: Jeff McCarrell < "mailto:jmccarre@akamai.com">jmccarre@akamai.com>
font-weight:bold">Cc: "m=
odperl@perl.apache.org
" <=
modperl@perl.apache.org
>
Subject=
:
Re: Best approach to store Application Configuration
v>
please correct me if I am wrong, I should be using tool like YA=
ML/Config::General for application configuration storage and reteieval, and=
load them on startup using startup.pl a> script? That would mean i will have to store the name of configuration f=
ile some where (probabaly in mod_perl configuration block in httpd.conf). <=
br>



--_000_CA40BED4342Ejmccarreakamaicom_--

Re: Best approach to store Application Configuration

am 12.07.2011 00:14:16 von mpeters

On 07/11/2011 05:41 PM, Jerry Pereira wrote:
> please correct me if I am wrong, I should be using tool like
> YAML/Config::General for application configuration storage and
> reteieval, and load them on startup using startup.pl
> script?

Yes.

> That would mean i will have to store the name of configuration
> file some where (probabaly in mod_perl configuration block in httpd.conf).

Again, if you think about just using a mod_perl specific way of doing
this you'll leave all of your non-mod_perl stuff out in the cold and any
project of significant size is going to have some non-mod_perl processes
involved somewhere.

I prefer to use environment variables if you need to specify the
location of a config file. These are available no matter where you're
running (in mod_perl you'll want to use a PerlPassEnv directive so the
mod_perl side sees it).

--
Michael Peters
Plus Three, LP

Re: Best approach to store Application Configuration

am 12.07.2011 00:33:01 von Keywan Ghadami

Hi Jerry,
I use JSON:XS in my framework, but
before writing a hole framework from the scratch, think about using
catalyst.
regards keywan




Am 11.07.2011 23:07, schrieb Jerry Pereira:
> Hi All,
>
> I am new to mod_perl (a java developer). I would like to know the best
> approach to store and retrieve Applicaiton configurations that is accessible
> to all packages in my mod_perl application.
>
> My application configuration includes - Database details, Template mapping,
> LDAP configuration details etc. I would like my to load all these
> configuratoins when my application starts and then on, i should be able to
> access these configuration from anywhere.
>
> For Example:
> my $dbDetails = ConfigUtil->getDBDetails(); //returns reference to hash
> my dbUser = dbDetails->user;
>
> I belive PerlSetVar only allows strings variables. I would like to get some
> suggestions on how configuration management in mod_perl applications.
>
> Thanks,
> Jerry
>


--
Mit freundlichen Grüßen
Keywan Ghadami
Telefon +49 (0)75 31 / 81 39 7 95
Fax +49 (0)75 31 / 81 39 7 89
Anschrift
ibson
Fritz-Arnold-Str. 23
D-78467 Konstanz